package com.gw.quotes.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gw.quotes.R;
import com.gw.quotes.domain.TradingRecord;
import com.gw.quotes.entity.business.Priceinfo.GoodsoptItem;

public class Goods2Adapter extends BaseAdapter {

	private List<GoodsoptItem> list;
	private Context context;
	private int resource;

	public Goods2Adapter(Context context, int layoutId, List<GoodsoptItem> list) {
		this.context = context;
		this.resource = layoutId;
		this.list = list;
	}

	@Override
	public int getCount() {
		return this.list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		GoodsoptItem tr = list.get(position);
		if (convertView == null) {
			convertView = LayoutInflater.from(this.context).inflate(
					this.resource, parent, false);
		}
		TextView goodsoptionalname_text = (TextView) convertView
				.findViewById(R.id.goodsoptionalname_text);
		TextView relativeprice_text = (TextView) convertView
				.findViewById(R.id.relativeprice_text);
		goodsoptionalname_text.setText(tr.getGoodsoptionalname());
		relativeprice_text.setText(String.format("￥%.2f",tr.getRelativeprice()));
		return convertView;
	}
}
